package com.xbongbong.paas.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.dto.FormDataListDTO;
import com.xbongbong.paas.pojo.dto.SubFormListDTO;
import com.xbongbong.paas.pojo.vo.ChildExpansionListVO;
import com.xbongbong.paas.pojo.vo.PaasFormDataEsListVO;
import com.xbongbong.paas.pojo.vo.PrePayBalanceListVO;
import com.xbongbong.paas.pojo.vo.PrePaymentBalanceListVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.helper.PageHelper;
import com.xbongbong.paas.toolbox.thread.TransmittableThreadLocalUtil;
import com.xbongbong.paas.toolbox.wrap.XbbResponse;
import com.xbongbong.pro.applist.pojo.vo.ListAppVO;
import com.xbongbong.pro.common.pojo.vo.DimensionViewPoJo;
import com.xbongbong.pro.constant.XbbProConstant;
import com.xbongbong.pro.detailtab.dto.DetailTabDataGetDTO;
import com.xbongbong.pro.detailtab.dto.OrderOnPinDTO;
import com.xbongbong.pro.enums.DistributorMarkEnum;
import com.xbongbong.pro.enums.SaasMarkEnum;
import com.xbongbong.pro.enums.errorcodes.SystemErrorCodeEnum;
import com.xbongbong.pro.knowledge.base.pojo.dto.KnowledgeListDTO;
import com.xbongbong.pro.product.pojo.dto.ProductStockWarningListDTO;
import com.xbongbong.pro.product.pojo.vo.ProductStockWarningListVO;
import com.xbongbong.pro.weblist.pojo.dto.NearCustomerDTO;
import com.xbongbong.pro.weblist.pojo.vo.CommunicateVO;
import com.xbongbong.pro.weblist.pojo.vo.NearCustomerListVO;
import com.xbongbong.pro.weblist.pojo.vo.WaitPurchaseDetailVO;
import com.xbongbong.pro.weblist.pojo.vo.WaitPurchaseProductVO;
import com.xbongbong.saas.constant.BasicConstant;
import com.xbongbong.saas.enums.XbbRefTypeEnum;
import com.xbongbong.saas.service.DistributorManageService;
import com.xbongbong.saas.service.PayBalanceService;
import com.xbongbong.saas.service.PaymentBalanceService;
import com.xbongbong.saas.service.SaasListService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * @author haibin.zhang
 * @version v1.0
 * @date 2019/1/31 10:14
 * @since v1.0
 */
@RestController
@RequestMapping(value = XbbProConstant.API_ROOT_PREFIX + "/list")
public class SaasListController {

    private static final Logger LOG = LoggerFactory.getLogger(SaasListController.class);

    @Resource
    private SaasListService saasListService;
    @Resource
    private PaymentBalanceService paymentBalanceService;
    @Resource
    private PayBalanceService payBalanceService;
    @Resource
    private DistributorManageService distributorManageService;

    /**
     * 获取客户数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/customer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String customerList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.customerList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取经销商列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/distributor", method = RequestMethod.POST)
    public String distributorList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.distributorList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取经销商区域视图数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/distributorArea", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String distributorAreaList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<ListAppVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                // formDataListDTO.setPlatform(PlatFormEnum.DINGTALK.getValue());
                formDataListDTO.setIsDistributorView(BasicConstant.ONE);
                PaasFormDataEsListVO paasFormDataEsListVO = saasListService.distributorList(formDataListDTO);
                List<PaasFormDataEntityExt> esEntities = paasFormDataEsListVO.getPaasFormDataESList();
                Integer totalCount = paasFormDataEsListVO.getPageHelper().getRowsCount();
                ListAppVO listAppVO = new ListAppVO();
                if (totalCount != null && totalCount != 0) {
                    listAppVO = distributorManageService.formatDistributorAppList(formDataListDTO, esEntities, totalCount);
                    listAppVO.setPageHelper(paasFormDataEsListVO.getPageHelper());
                    listAppVO.setBusinessType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
                    listAppVO.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
                    listAppVO.setTopPermissions(paasFormDataEsListVO.getTopPermissions());
                } else {
                    listAppVO.setList(new ArrayList<>());
                    listAppVO.setTotalCount(0);
                    listAppVO.setPageHelper(new PageHelper().setRowsCount(0));
                    listAppVO.setBusinessType(XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode());
                    listAppVO.setDistributorMark(DistributorMarkEnum.DISTRIBUTOR.getCode());
                    listAppVO.setTopPermissions(paasFormDataEsListVO.getTopPermissions());
                }
                listAppVO.setAddPermission(saasListService.getAppListAddPermission(paasFormDataEsListVO));
                response = new XbbResponse<>(listAppVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取经销商地图
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/distributorMap", method = RequestMethod.POST)
    public String distributorMap(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                formDataListDTO.setIsDistributorMap(1);
                PaasFormDataEsListVO formDataListVO = saasListService.distributorList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取经销商联系人列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/distributorContact", method = RequestMethod.POST)
    public String distributorContactList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.distributorContactList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取经销商跟进记录列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/distributorCommunicate", method = RequestMethod.POST)
    public String distributorCommunicateList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<CommunicateVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                CommunicateVO communicateVO = saasListService.distributorCommunicateList(formDataListDTO);
                response = new XbbResponse<>(communicateVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取库存查询列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/productStock", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String newProductStockList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.newProductStockList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 首页获取库存查询列表卡片
     * @param productStockWarningListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/productStock/warningListAjax", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String productStockWarningList(@RequestBody @Valid ProductStockWarningListDTO productStockWarningListDTO, BindingResult br) {
        XbbResponse<ProductStockWarningListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(SaasMarkEnum.SAAS.getCode(), XbbRefTypeEnum.PRODUCT.getCode(), null, productStockWarningListDTO.getDistributorMark());
                ProductStockWarningListVO formDataListVO = saasListService.productStockWarningList(productStockWarningListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 客户回收站
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/delCustomer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String delCustomerList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.delCustomerList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 客户公海池
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/publicCustomer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String publicCustomer(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.publicCustomer(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 线索回收站
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/delClue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String delClueList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), DistributorMarkEnum.OTHER.getCode());
                PaasFormDataEsListVO formDataListVO = saasListService.delClueList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 线索公海池
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/publicClue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String publicClue(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), DistributorMarkEnum.OTHER.getCode());
                PaasFormDataEsListVO formDataListVO = saasListService.publicClue(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取联系人数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/contact", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String contactList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), null, formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.contactList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取联系人数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/supplierContact", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String supplierContactList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.supplierContactList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取机会数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/opportunity", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String opportunityList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.opportunityList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取合同数据列表/订货单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/contract", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String contractList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                Integer distributorMark = formDataListDTO.getDistributorMark();
                if (Objects.equals(DistributorMarkEnum.DISTRIBUTOR.getCode(),distributorMark)) {
                    PaasFormDataEsListVO formDataListVO = saasListService.orderList(formDataListDTO);
                    response = new XbbResponse<>(formDataListVO);
                } else{
                    PaasFormDataEsListVO formDataListVO = saasListService.contractList(formDataListDTO);
                    response = new XbbResponse<>(formDataListVO);
                }
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取跟进记录数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/customerCommunicate", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String customerCommunicateList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.customerCommunicateList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取供应商数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/supplier", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String supplierList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.supplierList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取采购合同数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/purchase", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String purchaseList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.purchaseList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取采购退货数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/returnedPurchase", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String returnedPurchaseList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.returnedPurchaseList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取bom数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/bombill", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String bomBillList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.bombillList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取生产单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/productionOrder", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String productionOrderList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.productionOrderList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取装配出入库单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/assemble", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String assembleList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.assembleList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取入库单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/instock", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String instockList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.instockList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取出库单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/outstock", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String outstockList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.outstockList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取盘点单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/inventory", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String inventoryList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.inventoryList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取盘点单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/transfer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String transferList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.transferList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }
    /**
     * 获取发票数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/invoice", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String invoiceList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.invoiceList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取发票数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/purchaseInvoice", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String purchaseInvoiceList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.purchaseInvoiceList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }
    /**
     * 获取应收款数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/payment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String paymentList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.paymentList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    @RequestMapping(value = "/prepaymentBlance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String prepaymentBlanceList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PrePaymentBalanceListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PrePaymentBalanceListVO formDataListVO = paymentBalanceService.prepaymentBalanceList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取盘点单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/payPlan", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String payPlanList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.payPlanList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取附近客户数据列表
     * @param nearCustomerDTO
     * @param br
     * @returnPaasFormDataEsListVO
     */
    @RequestMapping(value = "/nearCustomer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String nearCustomerList(@RequestBody @Valid NearCustomerDTO nearCustomerDTO, BindingResult br) {
        XbbResponse<NearCustomerListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(SaasMarkEnum.SAAS.getCode(), XbbRefTypeEnum.CUSTOMER_MANAGEMENT.getCode(), null, nearCustomerDTO.getDistributorMark());
                NearCustomerListVO nearCustomerListVO = saasListService.nearCustomerList(nearCustomerDTO);
                response = new XbbResponse<>(nearCustomerListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取视图维度列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/getDimensionViews", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String dimensionViewList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<List<DimensionViewPoJo>> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                List<DimensionViewPoJo> dimensionViewPoJos = saasListService.dimensionViewList(formDataListDTO);
                response = new XbbResponse<>(dimensionViewPoJos);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取待入库列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/waitInstock", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String waitInstockList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.waitInstockList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取待出库列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/waitOutstock", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String waitOutstockList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.waitOutstockList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取待生产列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/waitProduce", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String waitProduceList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.waitProduceList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取待采购列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/waitPurchase", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String waitPurchaseList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.waitPurchaseList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取智能补货列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/smartReplenishment", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String smartReplenishment(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.smartReplenishment(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }
    /**
     * 获取产品数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/product", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String productList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.productListSuper(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取竞争对手列表
     */
    @RequestMapping(value = "/competitor",method = RequestMethod.POST,produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String competitorList(@RequestBody @Valid FormDataListDTO formDataListDTO,BindingResult br){
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()){
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        }else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO paasFormDataEsListVO = saasListService.competitorList(formDataListDTO);
                response = new XbbResponse<>(paasFormDataEsListVO);
            }catch (XbbException e){
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response,SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * @Author: wujian
     * @Description: 获取待采购产品详情
     * @Date: 下午4:04 2021/9/13
     * @Param: [formDataListDTO, br]
     * @return: java.lang.String
     **/
    @RequestMapping(value = "/getWaitPurchaseProductDetail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getWaitPurchaseProductDetail(@RequestBody @Valid DetailTabDataGetDTO detailTabDataGetDTO, BindingResult br) {
        XbbResponse<WaitPurchaseProductVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                WaitPurchaseProductVO waitPurchaseProductVO = saasListService.getWaitPurchaseProductDetail(detailTabDataGetDTO);
                response = new XbbResponse<>(waitPurchaseProductVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * @Author: wujian
     * @Description: 获取以销定购明细
     * @Date: 下午4:04 2021/9/13
     * @Param: [formDataListDTO, br]
     * @return: java.lang.String
     **/
    @RequestMapping(value = "/getorderOnPinDetail", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String getorderOnPinDetail(@RequestBody @Valid OrderOnPinDTO orderOnPinDTO, BindingResult br) {
        XbbResponse<WaitPurchaseDetailVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                WaitPurchaseDetailVO waitPurchaseDetailVO = saasListService.getorderOnPinDetail(orderOnPinDTO);
                response = new XbbResponse<>(waitPurchaseDetailVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取多规格产品数据展开项
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/childProduct", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String childProductList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<ChildExpansionListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                ChildExpansionListVO childExpansionListVO = saasListService.childProductList(formDataListDTO);
                response = new XbbResponse<>(childExpansionListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取仓库数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/warehouse", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String warehouseList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.warehouseList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取报价单列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/quotation", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String quotationList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.quotationList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取仓库数据列表(退货退款合同列表)
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/returnsAndRefunds", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String refundList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                Integer distributorMark = formDataListDTO.getDistributorMark();
                if (Objects.equals(DistributorMarkEnum.DISTRIBUTOR.getCode(),distributorMark)) {
                    PaasFormDataEsListVO formDataListVO = saasListService.returnList(formDataListDTO);
                    response = new XbbResponse<>(formDataListVO);
                } else{
                    PaasFormDataEsListVO formDataListVO = saasListService.refundList(formDataListDTO);
                    response = new XbbResponse<>(formDataListVO);
                }
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取仓库数据列表(退货退款合同列表)
     * @param subFormListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/subFormList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String subFormList(@RequestBody @Valid SubFormListDTO subFormListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.subFormList(subFormListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 回款单列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author 徐俊杰
     * @date 2019/11/13 10:17
     * @since v1.0
     */
    @RequestMapping(value = "/paymentSheet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String paymentSheetList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.paymentSheetList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 在线支付流水列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author zcp
     * @since v1.0
     * @version v1.0
     */
    @RequestMapping(value = "/onlinePaymentFlow", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String onlinePaymentFlow(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.onlinePaymentFlowList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 付款单列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author 徐俊杰
     * @date 2020/2/25 14:39
     * @since v1.0
     */
    @RequestMapping(value = "/paySheet", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String paySheetList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.paySheetList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 预付款列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author 徐俊杰
     * @date 2020/2/25 14:38
     * @since v1.0
     */
    @RequestMapping(value = "/prepayBalance", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String prepayBlanceList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PrePayBalanceListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PrePayBalanceListVO formDataListVO = payBalanceService.prepayBalanceList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 其他收入单列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author zcp
     * @since v1.0
     */
    @RequestMapping(value = "/otherIncome", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String otherIncomeList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.otherIncomeList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 其他支出单列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author zcp
     * @since v1.0
     */
    @RequestMapping(value = "/otherExpense", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String otherExpenseList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.otherExpenseList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 调拨单列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     */
    @RequestMapping(value = "/fundTransfer", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String fundTransferList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.fundTransferList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 报销单列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author chy
     * @date 2019/11/13 10:17
     * @since v1.0
     */
    @RequestMapping(value = "/reimbursementForm", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String reimbursementFormtList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.reimbursementFormList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }

        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 费用列表
     *
     * @param formDataListDTO 统一列表页入参
     * @param br 错误
     * @return java.lang.String
     * @author chy
     * @date 2019/11/13 10:17
     * @since v1.0
     */
    @RequestMapping(value = "/expense", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String expenseList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.expenseList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取库存流水
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/stockFlowBill", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String stockFlowBillList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.stockFlowBillList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取批次流水
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/batchFlowBill", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String batchFlowBillList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.batchFlowBillList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取信用额度数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/creditLimit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String creditLimitList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), null, formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.creditLimitList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取固定额度数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/creditFixedLimit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String creditFixedLimitList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), null, formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.creditFixedLimitList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取信用额度数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/creditTemporaryLimit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String creditTemporaryLimitList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), null, formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.creditTemporaryLimitList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取信用流水数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/creditCardBillLimit", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String creditCardBillLimitList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), null, formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.creditCardBillLimitList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取库存台账
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/stockStandingBook", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String stockStandingBookList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.stockStandingBookList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取产品序列号
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/productSerialList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String productSerialList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.productSerialList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取经销商账号
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/distributorAccount", method = RequestMethod.POST)
    public String distributorAccountList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.distributorAccountList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取优惠券活动列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/marketingActivity", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String marketingActivity(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.marketingActivity(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取优惠券活动列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/promotionActivity", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String promotionActivity(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.promotionActivity(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }



    /**
     * 获取核销记录列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/writeOffRecord", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String writeOffRecord(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.writeOffRecord(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取产品价目列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/productPriceList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String productPriceList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                PaasFormDataEsListVO formDataListVO = saasListService.productPriceList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 对账单列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/statement", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String statement(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.statement(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取市场活动列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/marketActivity", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String marketActivity(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), DistributorMarkEnum.OTHER.getCode());
                PaasFormDataEsListVO formDataListVO = saasListService.marketActivityList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取客户数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/clue", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String clueList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), DistributorMarkEnum.OTHER.getCode());
                PaasFormDataEsListVO formDataListVO = saasListService.clueList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }


    /**
     * 获取成本单数据列表
     * @param formDataListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/costAdjust", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String costAdjustList(@RequestBody @Valid FormDataListDTO formDataListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(formDataListDTO.getSaasMark(), formDataListDTO.getBusinessType(), formDataListDTO.getMenuId(), formDataListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.costAdjustList(formDataListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }

    /**
     * 获取知识条目数据列表
     * @param knowledgeListDTO
     * @param br
     * @return
     */
    @RequestMapping(value = "/knowledge", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public String knowledgeList(@RequestBody @Valid KnowledgeListDTO knowledgeListDTO, BindingResult br) {
        XbbResponse<PaasFormDataEsListVO> response;
        if (br.hasErrors()) {
            String errMsg = Objects.requireNonNull(br.getFieldError()).getDefaultMessage();
            response = new XbbResponse<>(SystemErrorCodeEnum.API_ERROR_100002, errMsg);
        } else {
            try {
                TransmittableThreadLocalUtil.setValue(knowledgeListDTO.getSaasMark(), knowledgeListDTO.getBusinessType(), knowledgeListDTO.getMenuId(), knowledgeListDTO.getDistributorMark());
                PaasFormDataEsListVO formDataListVO = saasListService.knowledgeList(knowledgeListDTO);
                response = new XbbResponse<>(formDataListVO);
            } catch (XbbException e) {
                response = new XbbResponse<>(e);
            }
        }
        return JSON.toJSONString(response, SerializerFeature.DisableCircularReferenceDetect);
    }
}
